<%--
  Created by IntelliJ IDEA.
  User: 愿黑星照常升起
  Date: 2023/11/27
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.xaut.bean.Goods" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="cn.edu.xaut.bean.User" %>
<html>
<head>
    <title>我的购物车</title>
    <link rel="stylesheet" href="./static/plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="./static/plugins/bootstrap-3.4.1-dist/js/bootstrap.js">

</head>
<body>
<jsp:include page="header.jsp"></jsp:include>

<%
    User user1=(User)session.getAttribute("user");
    if(user1.getId()==0){
%>

<script>
    window.alert("请先登录");
    window.location.href ="login.jsp";
</script>


<%
        return;
    }
%>

<%
    ArrayList<Goods> GoodsCarts = (ArrayList<Goods>) session.getAttribute("goodscarts");
%>
<div class="container">
    <div class="goods">
        <%
            if (GoodsCarts == null ) {
                out.println("您的购物车内没有商品");

            } else {
                int i=0;
                for (Goods goods : GoodsCarts) {

        %>
        <% if (i%2==0) { %>
        <div class="row">
            <% }i++; %>

            <div class="col-md-3">
                <img src="./static/img/1.jpg" alt="" class="img-responsive">
            </div>
            <div class="col-md-3">
                <form name="OrderForm" action="userCartServlet" method="post">
                    <input type="hidden" name="goodsid" value="<%= goods.getId()%>">
                    <h3>商品1:<%= goods.getGoodsname()%></h3>
                    <p>商品价格:<%= goods.getGoodsprice()%>￥</p>
                </form>
            </div>

            <% if (i%2==0) { %>
        </div>

        <% } %>
        <%
                }
            }
        %>

        <br>
        <div class="row">
            <div style="text-align: center">
                <h3>总金额:<%= session.getAttribute("totalprice")%>￥</h3>
                <img src="static/img/2.png" style="height: 90px;width: 90px;">
            </div>
        </div>
    </div>
</div>


<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>
